package guda.house.biz.form.village;

import guda.house.dal.dataobject.ParkingDO;

import java.text.SimpleDateFormat;

/**
 * Created by well on 15/11/15.
 */
public class ParkingEditForm extends ParkingForm{
    private Long parkingId;

    public Long getParkingId() {
        return parkingId;
    }

    public void setParkingId(Long parkingId) {
        this.parkingId = parkingId;
    }

    public ParkingDO toDO(){
        ParkingDO parkingDO = super.toDO();
        parkingDO.setParkingId(parkingId);
        return parkingDO;
    }

    public void initForm(ParkingDO parkingDO){
        setParkingId(parkingDO.getParkingId());
        setOwnerType(parkingDO.getOwnerType());
        setMemo(parkingDO.getMemo());
        setCarNo(parkingDO.getCarNo());
        setOwnerId(parkingDO.getOwnerId());
        setParkingTypeId(parkingDO.getParkingTypeId());
        setVillageId(parkingDO.getVillageId());
        setParkingCard(parkingDO.getParkingCard());
        setParkingName(parkingDO.getParkingName());
        setBuyed(parkingDO.getBuyed());
        if(parkingDO.getGmtStart()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtStart(simpleDateFormat.format(parkingDO.getGmtStart()));
        }
        if(parkingDO.getGmtEnd()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtEnd(simpleDateFormat.format(parkingDO.getGmtEnd()));
        }
    }
}
